{% extends "base.html" %}
{% load i18n %}

{% load humanize %}
{% load fftogo_tags %}

{% block title %}{% endblock %}

{% block rss %}
    <link rel="alternate" type="application/atom+xml" href="{{ request.path }}?output=atom{% if request.GET.search %}&search={{ request.GET.search }}{% endif %}" />
{% endblock %}

{% block above_content %}
    {% if request.GET.message %}
        <div class="message">
            {% ifequal request.GET.message 'settings' %}
                {% trans "Did you know that you can " %}<a href="{% url settings %}">{% trans "change your font size and other settings</a>?" %}。
            {% endifequal %}
            {% ifequal request.GET.message 'shared' %}
                {% trans "Entry created" %}
                -
                <a href="{% url entry_delete request.GET.entry %}"?next={{ request.path }}">{% trans "Undo" %}</a>
            {% endifequal %}
            {% ifequal request.GET.message 'deleted' %}
                {% if request.GET.comment %}
                    {% trans "Comment deleted" %}
                    -
                    <a href="{% url comment_undelete request.GET.entry,request.GET.comment %}?next={{ request.path }}">{% trans "Undo" %}</a>
                {% else %}
                    {% trans "Entry deleted" %}
                    -
                    <a href="{% url entry_undelete request.GET.entry %}"?next={{ request.path }}">{% trans "Undo" %}</a>
                {% endif %}
            {% endifequal %}
            {% ifequal request.GET.message 'edited' %}
                {% trans "Comment edited" %}
            {% endifequal %}
            {% ifequal request.GET.message 'commented' %}
                {% trans "Comment created" %}
                -
                <a href="{% url comment_delete request.GET.entry,request.GET.comment %}?next={{ request.path }}">{% trans "Undo" %}</a>
            {% endifequal %}
            {% ifequal request.GET.message 'liked' %}
                {% trans "Entry liked" %}
                -
                <a href="{% url entry_unlike request.GET.entry %}?next={{ request.path }}">{% trans "Undo" %}</a>
            {% endifequal %}
            {% ifequal request.GET.message 'un-liked' %}
                {% trans "Entry un-liked" %}
                -
                <a href="{% url entry_like request.GET.entry %}?next={{ request.path }}">{% trans "Undo" %}</a>
            {% endifequal %}
            {% ifequal request.GET.message 'hidden' %}
                {% trans "Entry hidden" %}
                -
                <a href="{% url entry_unhide request.GET.entry %}?next={{ request.path }}">{% trans "Undo" %}</a>
            {% endifequal %}
            {% ifequal request.GET.message 'un-hidden' %}
                {% trans "Entry un-hidden" %}
                -
                <a href="{% url entry_hide request.GET.entry %}?next={{ request.path }}">{% trans "Undo" %}</a>
            {% endifequal %}
            {% ifequal request.GET.message 'unsubscribed' %}
                {% trans "Unsubscribed from " %}<a href="{% url user profile.nickname %}">{% firstof profile.name profile.nickname %}</a>
                -
                <form style="display: inline;" method="post" action="{% url user_subscribe profile.nickname %}">
                    <input type="submit" value="{% trans "Undo" %}" />
                </form>
            {% endifequal %}
            {% ifequal request.GET.message 'subscribed' %}
                {% trans "Subscribed to " %}<a href="{% url user profile.nickname %}">{% firstof profile.name profile.nickname %}</a>
                -
                <form style="display: inline;" method="post" action="{% url user_unsubscribe profile.nickname %}">
                    <input type="submit" value="{% trans "Undo" %}" />
                </form>
            {% endifequal %}
        </div>
    {% endif %}
    {% block above_share %}
    {% endblock %}
    {% block share %}
        {% if request.session.nickname and not request.GET.start %}
            <form method="post" action="/share/" enctype="multipart/form-data">
                <input type="hidden" name="next" value="{{ request.path }}" />
                {% block extra_post %}{% endblock %}
                <textarea id="status" name="title" rows="2" style="width: 100%; max-width: 400px; overflow: hidden;" onpropertychange="this.style.height=this.scrollHeight+'px';" oninput="this.style.height=this.scrollHeight+'px';"></textarea>
                <br/><span id="link"><input name="link" type="text" />  {% trans "Link url" %}<br/></span>
                <span id="imageurl"><input name="imageurl" type="text" />  {% trans "Image url" %}<br/></span>
                <input type="submit" value="{% block share_button_value %}{% trans "Share" %}{% endblock %}" /> {% trans "Add:" %}  <a href="#" class="addlink">{% trans "Link" %}</a> - <a href="#" class="addimage">{% trans "Image" %}</a> 
            </form>
        {% endif %}
    {% endblock %}
    {% block below_share %}
    {% endblock %}
{% endblock %}

{% block content %}
    <ul class="entries">
        {% for entry in entries %}
            <li id="{{ entry.id }}" class="entry {% cycle even,odd %}">
            {% if not entry.hidden %}
                <div class="icon">
                    <a href="{{ request.path }}?service={{ entry.service.id }}{% if request.GET.search %}&search={{ request.GET.search }}{% endif %}{% if request.GET.url %}&url={{ request.GET.url }}{% endif %}"><img src="{{ entry.service.iconUrl|iconproxy }}" alt="{{ entry.service.name }}" /></a> 
                </div>
                {% block summary %}
                  <div class="summary">
                      {% block room_prefix %}
                          {% if entry.room %}
                              <a href="{% url room entry.room.nickname %}">{{ entry.room.name }}</a>:
                          {% endif %}
                      {% endblock %}
                      {% block user_prefix %}
                          {% if not entry.anonymous %}
                              {% if not entry.user.nickname %}
                                  <a href="{% url user entry.user.id %}">{{ entry.user.name }}</a>
                              {% else %}
                                  <a href="{% url user entry.user.nickname %}">{% ifequal request.session.nickname entry.user.nickname %}You{% else %}{{ entry.user.name }}{% endifequal %}</a>
                              {% endif %}
                          {% endif %}
                      {% endblock %}
                      {% block friend_of %}
                          {% if entry.friendof %}
                              ({% url user entry.friendof.nickname as myurl %}{% blocktrans with entry.friendof.name as friendofname%}friend of <a href="{{myurl}}">{{ friendofname }}</a>{% endblocktrans %})
                          {% endif %}
                      {% endblock %}
                      {% ifnotequal entry.service.id 'internal' %}
                          {% if not entry.anonymous %}
                              -
                          {% endif %}
                          <a href="{{ entry.service.profileUrl }}">{{ entry|summary }}</a>
                      {% endifnotequal %}
                      {% ifnotequal entry.user.nickname request.session.nickname %}<a href="#" title="{% trans "Reply to " %} {{ entry.user.name }}" class="reply" eid="{{ entry.id }}"> <img src="/static/images/reply.png" alt="@{{ entry.user.name }}"> </a>{% endifnotequal %}
                  </div>
                {% endblock %}
                <div class="title">
                    {% ifequal entry.service.id 'twitter' %}
                        {% if request.session.googlemobileproxy %}
                            "{{ entry.title|urlizetrunc:30|twitterize|gmpize|safe }}"
                        {% else %}
                            "{{ entry.title|urlizetrunc:30|twitterize|safe }}"
                        {% endif %}
                    {% else %}
                        {% if entry|is_message %}
                            {% if request.session.googlemobileproxy %}
                                "{{ entry.title|urlizetrunc:30|gmpize|safe }}"
                            {% else %}
                                "{{ entry.title|urlizetrunc:30 }}"
                            {% endif %}
                        {% else %}
                            <a href="{% if request.session.googlemobileproxy %}{{ entry.link|gmpize:1 }}{% else %}{{ entry.link }}{% endif %}"{% if request.session.newwindow %} target="_blank"{% endif %}>{{ entry.title }}</a>
                        {% endif %}
                    {% endifequal %}
                </div>
                {% if entry.media and not request.session.nomedia %}
                    <div class="media">
                        {% for media in entry.media|filter_media %}
                            {% if media.thumbnails %}
                                {% for thumbnail in media.thumbnails|filter_thumbnails %}
                                    <a href="{% firstof media.link entry.link %}"{% if request.session.newwindow %} target="_blank"{% endif %}"><img src="{{ thumbnail.url }}" alt="{% firstof thumbnail.title media.title entry.title %}" title="{% firstof thumbnail.title media.title entry.title %}" /></a>
                                {% endfor %}
                            {% endif %}
                        {% endfor %}
                    </div>
                {% endif %}
                <div class="meta">
                    <a class="permalink" href="{% url entry entry.id %}" title="{{ entry.updated}}">{{ entry.updated|timesince }}{% trans " ago" %}</a>
                    {% if entry.via %}
                        {% trans "via " %}<a class="via" href="{{ entry.via.url }}">{{ entry.via.name }}</a>
                    {% endif %}
                    {% block related %}
                        {% if not entry|is_message %}
                            -
                            <a href="{% url related %}?url={{ entry.link|urlencode }}">{% trans "Related" %}</a>
                        {% endif %}
                    {% endblock %}
                    {% if request.session.nickname %}
                        -
                        <a href="{% url entry_comment entry.id %}?next={{ request.path }}">{% trans "Comment" %}</a>
                        {% if entry|likeable:request.session.nickname %}
                            {% if not request.session.nickname|liked:entry %}
                                -
                                <a href="{% url entry_like entry.id %}?next={{ request.path }}">{% trans "Like" %}</a>
                            {% endif %}
                        {% endif %}
                        {% block hide %}
                            -
                            <a href="{% url entry_hide entry.id %}?next={{ request.path }}">{% trans "Hide" %}</a>
                        {% endblock %}
                        {% ifequal entry.user.nickname request.session.nickname %}
                            -
                            <a href="{% url entry_delete entry.id %}?next={{ request.path }}">{% trans "Delete" %}</a>
                        {% else %}
                            {% if room %}
                                {% if request.session.nickname|is_admin:profile %}
                                    -
                                    <a href="{% url entry_delete entry.id %}?next={{ request.path }}">{% trans "Delete" %}</a>
                                {% endif %}
                            {% endif %}
                        {% endifequal %}
                    {% endif %}
                    {% if entry.likes %}
                        <div class="likes">
                            {% for like in entry.likes|shorten_likes:entries %}
                                {% if forloop.last %}
                                    {% if not forloop.first %}
                                        {% trans "and" %}
                                    {% endif %}
                                {% endif %}
                                {% if like.permalink %}
                                    <a href="{% url entry entry.id %}">{% blocktrans with like.num as likenum %}{{ likenum }} other people{% endblocktrans %}</a>
                                {% else %}
                                    <a href="{% url user like.user.nickname %}">{% ifequal like.user.nickname request.session.nickname %}{% trans "You" %}{% else %}{{ like.user.name }}{% endifequal %}</a>
                                {% endif %}
                            {% endfor %}
                            {% trans "liked this" %}
                            {% if request.session.nickname|liked:entry %}
                                (<a href="{% url entry_unlike entry.id %}?next={{ request.path }}">{% trans "Un-like" %}</a>)
                            {% endif %}
                        </div>
                    {% endif %}
                    {% if entry.comments %}
                        <ul class="comments">
                            {% block e_shortencomments %}{% endblock %}
                            {% block shortencomments %}{% for comment in entry.comments|set_shorten_comments:request.session.commentsinlist %}
                                {% if comment.permalink %}
                                    <li class="permalink">
                                        <a href="{% url entry entry.id %}">{% blocktrans count comment.num as commentnum%}{{ commentnum }} more comment{% plural %} {{ commentnum }} more comments{%endblocktrans%}</a>
                                    </li>
                                {% else %}
                                    <li id="{{ comment.id }}" class="comment {% ifequal comment.user.nickname request.session.nickname %}yourcomment{% endifequal %}">
                                        {% if request.session.googlemobileproxy %}
                                            {{ comment.body|urlizetrunc:30|gmpize|safe }}
                                        {% else %}
                                            {{ comment.body|urlizetrunc:30 }}
                                        {% endif %}
                                        -
                                        <a href="{% url user comment.user.nickname %}">{% ifequal comment.user.nickname request.session.nickname %}You{% else %}{{ comment.user.name }}{% endifequal %}</a>
                                        -
                                        <span title="{{ comment.date }}">{{ comment.date|timesince }}{% trans " ago" %}</span>
                                        {% if comment.via %}
                                            {% trans "via " %}<a class="via" href="{{ comment.via.url }}">{{ comment.via.name }}</a>
                                        {% endif %}
                                        {% ifequal request.session.nickname comment.user.nickname %}
                                            (<a href="{% url entry_comment entry.id %}?comment={{ comment.id }}&body={{ comment.body|urlencode }}&next={{ request.path }}">{% trans "edit" %}</a>
                                            |
                                            <a href="{% url comment_delete entry.id,comment.id %}?next={{ request.path }}">{% trans "delete" %}</a>)
                                        {% else %}
                                            {% ifequal request.session.nickname entry.user.nickname %}
                                                (<a href="{% url comment_delete entry.id,comment.id %}?next={{ request.path }}">{% trans "delete" %}</a>)
                                            {% else %}
                                                {% if room %}
                                                    {% if request.session.nickname|is_admin:profile %}
                                                        (<a href="{% url comment_delete entry.id,comment.id %}?next={{ request.path }}">{% trans "delete" %}</a>)
                                                    {% endif %}
                                                {% endif %}
                                            {% endifequal %}
                                        {% endifequal %}
                                        {% ifnotequal comment.user.nickname request.session.nickname %}
                                        <a href="#" title="{% trans "Reply to " %}{{ comment.user.name }}" class="reply" eid="{{entry.id}}"> <img src="/static/images/reply.png" alt="@{{ comment.user.name }}"> </a>
                                        {% endifnotequal %}
                                    </li>
                                {% endif %}
                            {% endfor %}{% endblock %}
                        </ul>
                    {% endif %}
                    <ul class="cocomment">
                    <li id="{{ comment.id }}" class="comment">
                    <form method="post" action="{% url entry_comment entry.id %}">
                        <textarea id="e-{{entry.id}}" rows="1" cols="40" name="body" class="commentbody" style="width: 100%; max-width: 400px; overflow: hidden;" onpropertychange="this.style.height=this.scrollHeight+'px';" oninput="this.style.height=this.scrollHeight+'px';"></textarea>
                        <input type="hidden" name="comment" />
                        <input type="hidden" name="entry" value="{{entry.id}}" />
                        <input type="hidden" name="next" value="{% url entry entry.id %}" /><br/>
                        <input type="submit" value="{% trans "Post" %}" /> {% block cancel %}<a href="#" class="cancel" cid="{{entry.id}}">{%trans "Cancel" %}</a>{% endblock %}{% block reset %}{% endblock %}
                    </form>
                    </li>
                    </ul>
                </div>
            {% else %}
                <a href="http://friendfeed.com/e/{{ entry.id }}" class="hidden">{% trans "Entry hidden" %}</a>
            {% endif %}
            </li>
        {% endfor %}
    </ul>
    {% if hidden %}
        <div class="hidden">
            {% blocktrans count hidden|length as hiddenlength%}{{ hiddenlength }} entry hidden{% plural %}{{ hiddenlength }} entries hidden{% endblocktrans %}
        </div>
    {% endif %}
{% endblock %}

{% block below_content %}
    <div id="nav">
        {%if not permalink %}
            {% if has_previous %}
                7
                <a href="{{ request.path }}?start={{ previous }}{% if request.GET.service %}&service={{ request.GET.service }}{% endif %}{% if request.GET.search %}&search={{ request.GET.search }}{% endif %}{% if request.GET.url %}&url={{ request.GET.url }}{% endif %}" accesskey="7">{% trans "Previous" %}</a>
            {% endif %}
            9
            <a href="{{ request.path }}?start={{ next }}{% if request.GET.service %}&service={{ request.GET.service }}{% endif %}{% if request.GET.search %}&search={{ request.GET.search }}{% endif %}{% if request.GET.url %}&url={{ request.GET.url }}{% endif %}" accesskey="9">{% trans "Next" %}</a>
        {% endif %}
        *
        <a href="#top" accesskey="*">{% trans "Top" %}</a>
    </div>
{% endblock %}
